#ifndef mealview_h
#define mealview_h

#include "juce_amalgamated.h"
#include "../FoodObjects/Meal.h"
#include "EatableView.h"
#include "PersistentFoodList.h"
#include "../Recipe.h"
#include <iostream>

class MealView: public EatableView
{
private:
	Meal* meal;
	TextLayout ingredientLayout;
	TextLayout directionLayout;
	TextLayout timeLayout;
	String text;

public:
	MealView()
	{
	}

	void paintExtra(Graphics& g)
	{
		cout << eatable->id << endl;
		Recipe& r = PersistentFoodList::instance().getRecipes()[eatable->id];

		ingredientLayout = r.getIngredients();
		directionLayout = r.getDirections();
		timeLayout = r.getTimes();

		resized();
		g.setColour(Colours::lightgrey);
		g.drawRect(getImageWidth() + 2 * spacer, spacer, getWidth() - (getImageWidth() + 3 * spacer),
				getImageWidth());
		g.drawRect(spacer, getImageWidth() + 2 * spacer, getWidth() - 2 * spacer, getHeight()
				- getImageWidth() - 3 * spacer);

		g.setColour(Colours::black);
		timeLayout.draw(g, getImageWidth() + 3 * spacer, getImageWidth() - 75);
		ingredientLayout.draw(g, getImageWidth() + 3 * spacer, 2 * spacer);
		directionLayout.draw(g, 2 * spacer, getImageWidth() + 4 * spacer);
	}

	void resized()
	{
		timeLayout.layout(getWidth() - getImageWidth() - (2 * spacer), Justification::left, true);
		ingredientLayout.layout(getWidth() - getImageWidth() - (2 * spacer), Justification::left, true);
		directionLayout.layout(getWidth() - 4 * spacer, Justification::left, true);
	}
};

#endif
